home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / LgcyPlus / disk2 / SYSTCHD._ / SYSTCHD.
Encoding:
Text File  |  2001-03-02  |  3.4 KB  |  103 lines

  1. 10    ! **************************************************************
  2. 20    ! Example: SYSTEM Widget As a Child
  3. 30    !
  4. 40    ! This program shows the user of the SYSTEM widget as a child
  5. 50    ! widget. The program displays a PANEL widget, puts a PRINTER
  6. 60    ! widget on it, and then creates a SYSTEM widget containing an
  7. 70    ! array of buttons. When you click a button, the event is listed
  8. 80    ! in the PRINTER widget.
  9. 90    !
  10. 100   ! **************************************************************
  11. 110   !
  12. 120   CLEAR SCREEN
  13. 130   INTEGER D(1:4),Dw,Dh,Nlines    ! Display handling variables
  14. 140   INTEGER Px,Py,Pw,Ph            ! Main PANEL parameters
  15. 150   INTEGER Gx,Gy                  ! Internal spacing
  16. 160   INTEGER Nr,Nc,R,C,Bx,By,Bw,Bh  ! PUSHBUTTON variables
  17. 170   INTEGER Prx,Pry,Prw,Prh        ! PRINTER parameters
  18. 180   DIM Ev$(1:2)[50],S$[50]        ! Returns event source - GP string
  19. 190   !
  20. 200   ! Set up a PANEL in the center of the printing display (above the
  21. 210   ! display (above the softkeys, etc.) and put a SYSTEM MENU on it
  22. 220   ! so you can quit the program.
  23. 230   !
  24. 240   STATUS CRT,13;Nlines
  25. 250   GESCAPE CRT,3;D(*)
  26. 260   Dw=D(3)-D(1)
  27. 270   Dh=(D(4)-D(2))*((Nlines-7)/Nlines)
  28. 280   !
  29. 290   Pw=Dw*.9
  30. 300   Ph=Dh*.9
  31. 310   Px=(Dw-Pw)/2
  32. 320   Py=(Dh-Ph)/2
  33. 330   !
  34. 340   ASSIGN @Main TO WIDGET "PANEL";SET ("VISIBLE":0)
  35. 350   CONTROL @Main;SET ("X":Px,"Y":Py,"WIDTH":Pw,"HEIGHT":Ph)
  36. 360   CONTROL @Main;SET ("SYSTEM MENU":"Quit")
  37. 370   CONTROL @Main;SET ("MAXIMIZABLE":0,"RESIZABLE":0)
  38. 380   CONTROL @Main;SET ("TITLE":" Example: SYSTEM Widget As a Child")
  39. 390   STATUS @Main;RETURN ("INSIDE WIDTH":Iw,"INSIDE HEIGHT":Ih)
  40. 400   !
  41. 410   ! Create a SYSTEM widget as a child of the main PANEL and
  42. 420   ! populate with PUSHBUTTONS.
  43. 430   !
  44. 440   ASSIGN @Sys TO WIDGET "SYSTEM";PARENT @Main
  45. 450   !
  46. 460   Gx=Iw*.02
  47. 470   Gy=Gx
  48. 480   !
  49. 490   Nr=9
  50. 500   Nc=6
  51. 510   Bh=(Ih-2*Gy)/Nr
  52. 520   Bw=Iw*.08
  53. 530   !
  54. 540   FOR R=1 TO Nr
  55. 550     By=Gy+(R-1)*Bh
  56. 560     FOR C=1 TO Nc
  57. 570       Bx=Gx+(C-1)*Bw
  58. 580       S$="B"&VAL$(R)&VAL$(C)
  59. 590       CONTROL @Sys;SET ("*NAME":S$,"*CREATE":"PUSHBUTTON")
  60. 600       CONTROL @Sys;SET ("X":Bx,"Y":By,"WIDTH":Bw,"HEIGHT":Bh)
  61. 610       CONTROL @Sys;SET ("LABEL":S$)
  62. 620     NEXT C
  63. 630   NEXT R
  64. 640   !
  65. 650   ! Set up a PRINTER widget on the main PANEL (not as part of
  66. 660   ! the SYSTEM widget) to log events.
  67. 670   !
  68. 680   Prw=Iw-(Nc*Bw+3*Gx)
  69. 690   Prh=Ih-2*Gy
  70. 700   Prx=Iw-(Prw+Gy)
  71. 710   Pry=Gy
  72. 720   ASSIGN @Prn TO WIDGET "PRINTER";PARENT @Main
  73. 730   CONTROL @Prn;SET ("X":Prx,"Y":Pry,"WIDTH":Prw,"HEIGHT":Prh)
  74. 740   !
  75. 750   ! Set up an event to trap the PUSHBUTTONs in the SYSTEM widget.
  76. 760   !
  77. 770   ON EVENT @Sys,"ACTIVATED" GOSUB Handler
  78. 780   !
  79. 790   ! Set event to quit on SYSTEM MENU, make whole thing visible,
  80. 800   ! loop and wait for an event.
  81. 810   !
  82. 820   ON EVENT @Main,"SYSTEM MENU" GOTO Finis
  83. 830   CONTROL @Main;SET ("VISIBLE":1)
  84. 840   !
  85. 850   LOOP
  86. 860     WAIT FOR EVENT
  87. 870   END LOOP
  88. 880   STOP
  89. 890   !
  90. 900   ! This event handler confirms PUSHBUTTON events by printing out
  91. 910   ! the event and its source.
  92. 920   !
  93. 930 Handler:  !
  94. 940   STATUS @Sys;RETURN ("*QUEUED EVENT":Ev$(*))
  95. 950   S$="Name/Event: "&Ev$(1)&"/"&Ev$(2)
  96. 960   CONTROL @Prn;SET ("APPEND TEXT":S$)
  97. 970   RETURN
  98. 980   !
  99. 990 Finis:  !
  100. 1000  ASSIGN @Main TO *       ! Delete PANEL widget
  101. 1010  CLEAR SCREEN
  102. 1020  END
  103.